<template>
	<view class="index">
		<view class="list_item_wrap">
			<view class="list_item" v-for="item in list" :key="item.traineeId">
				<view class="list_item_c">
					<img :src="item.avatar" alt="">
					<view class="info">
						<view class="top">
							<view class="name bt"><text>姓名：</text>{{item.userName}}</view>
							<view class="sex bt"><text>性别：</text>{{item.gender == 0 ? '男 ' : '女'}}</view>
							<view class="phone"><text>手机号：</text>173009333</view>
						</view>
						<view class="date">
							<u-icon name="clock"></u-icon>
							<text>入学日期：{{item.createdTime}}</text>
						</view>
					</view>
				</view>

				<view class="u-page__button-item" @click="onDelTrainee(item.traineeId)">
					<u-button
					    text="删除"
					    size="small"
					    type="error"
					></u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import {queryTraineeList, delTrainee} from '../../common/api'
	export default {
		data() {
			return {
				list: [],
				userData: uni.getStorageSync('userData'),
			}
		},
		onLoad() {
			this.getQueryTraineeList()
		},
		methods: {
			async getQueryTraineeList(){
				let res = await queryTraineeList(this.userData.user.coachId)
				this.list = res
			},
			async onDelTrainee(id){
				let res = await delTrainee(id)
				uni.$u.toast('删除成功')
				this.getQueryTraineeList()
			}
		}
	}
</script>

<style lang="scss" scoped>
.index {
	.list_item_wrap {
		margin: 32rpx;
		padding-bottom: 32rpx;
		.list_item {
			background: #f5f5f5;
			padding: 20rpx;
			border-radius: 20rpx;
			margin-bottom: 32rpx;
			.list_item_c {
				display: flex;
				
				img {
					width: 180rpx;
					height: 180rpx;
					border-radius: 50%;
				}
				.info {
					width: calc(100% - 180rpx);
					margin-left: 20rpx;
					display: flex;
					flex-flow: column;
					justify-content: space-between;
					.top {
						font-size: $uni-font-size-small;
						font-weight: bold;
						text {
							font-weight: 400;
							color: $uni-color-type1;
						}
						.bt {
							margin-bottom: 8rpx;
						}
					}
					.date {
						display: flex;
						color: $uni-color-type1;
						font-size: $uni-font-size-mini;
					}
				}
			}
			.u-page__button-item {
				
				.u-button {
					width: 100rpx !important;
					margin-top: 30rpx;
					margin-right: 0;
				}
			}
		}
		
	}
}
</style>
